package math;

public class DayOfTheYear1154 {
    int[] runDay = new int[]{31,29,31,30,31,30,31,31,30,31,30,31};

    int[] notRunDay = new int[]{31,28,31,30,31,30,31,31,30,31,30,31};

    public int dayOfYear(String date) {
        String[] dates = date.split("-");
        Integer year = Integer.valueOf(dates[0]);
        Integer month = Integer.valueOf(dates[1]);
        Integer day = Integer.valueOf(dates[2]);
        boolean isRun = false;
        if(year%100==0&&year%400==0){
            isRun = true;
        }else if(year%100!=0&&year%4==0){
            isRun = true;
        }

        int result = 0;
        for (int i = 0; i < month-1; i++) {
            if(isRun){
                result+=runDay[i];
            }else {
                result+=notRunDay[i];
            }
        }
        return result+day;
    }
}
